INPUT$ Function ---------------------------------------------------------------------------- Action Returns a string of characters read from the specified file. Syntax INPUT$( n , # filenumber% ) Remarks The INPUT$ statement uses the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- n The number of characters (bytes) to read from the file. filenumber% The number that was used in the Argument Description ---------------------------------------------------------------------------- filenumber% The number that was used in the OPEN statement to open the file. If the file is opened for random access, the argument n must be less than or equal to the record length set by the LEN clause in the OPEN statement (or less than or equal to 128 if the record length is not set). If the given file is opened for binary or sequential access, n must be less than or equal to 32,767. If filenumber% is omitted, the characters are read from the standard input device. (If input has not been redirected, the keyboard is the standard input device.) You can use the DOS redirection symbols (<, >, or >>) or the pipe symbol ( | ) to redefine the standard input or standard output for an executable file created with BASIC. (See your operating-system manual for a complete discussion of redirection and pipes.) Unlike the INPUT # statement, INPUT$ returns all characters it reads. Example The following example uses I NPUT$ to read one character at a time from a file. The input character is converted to standard printable ASCII, if necessary, and displayed on the screen. ' ASCII codes for tab and line feed. DEFINT A-Z CONST HTAB = 9, LFEED = 10 CLS ' Clear screen. INPUT "Display which file"; Filename$ OPEN Filename$ FOR INPUT AS #1 DO WHILE NOT EOF(1) ' Input a single character from the file. S$ = INPUT$(1, #1) ' Convert the character to an integer and turn off the high bit ' so WordStar files can be displayed. C = ASC(S$) AND &H7F ' Is it a printable character? IF (C >= 32 AND C <= 126) OR C = HTAB OR C = LFEED THEN PRINT CHR$(C); LOOP END